/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entitys;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

/**
 *
 * @author Administrator
 */
@Entity
@Table(name = "rating")
@NamedQueries({
    @NamedQuery(name = "Rating.findAll", query = "SELECT r FROM Rating r"),
    @NamedQuery(name = "Rating.findByVideoid", query = "SELECT r FROM Rating r WHERE r.videoid = :videoid"),
    @NamedQuery(name = "Rating.findByRating", query = "SELECT r FROM Rating r WHERE r.rating = :rating"),
    @NamedQuery(name = "Rating.findByLikes", query = "SELECT r FROM Rating r WHERE r.likes = :likes"),
    @NamedQuery(name = "Rating.findByDislikes", query = "SELECT r FROM Rating r WHERE r.dislikes = :dislikes"),
    @NamedQuery(name = "Rating.findByViews", query = "SELECT r FROM Rating r WHERE r.views = :views")})
public class Rating implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "videoid")
    private Integer videoid;
    @Column(name = "rating")
    private Integer rating;
    @Column(name = "likes")
    private Integer likes;
    @Column(name = "dislikes")
    private Integer dislikes;
    @Column(name = "views")
    private Integer views;
    @JoinColumn(name = "videoid", referencedColumnName = "id", insertable = false, updatable = false)
    @OneToOne(optional = false)
    private Video video;

    public Rating() {
    }

    public Rating(Integer videoid) {
        this.videoid = videoid;
    }

    public Integer getVideoid() {
        return videoid;
    }

    public void setVideoid(Integer videoid) {
        this.videoid = videoid;
    }

    public Integer getRating() {
        return rating;
    }

    public void setRating(Integer rating) {
        this.rating = rating;
    }

    public Integer getLikes() {
        return likes;
    }

    public void setLikes(Integer likes) {
        this.likes = likes;
    }

    public Integer getDislikes() {
        return dislikes;
    }

    public void setDislikes(Integer dislikes) {
        this.dislikes = dislikes;
    }

    public Integer getViews() {
        return views;
    }

    public void setViews(Integer views) {
        this.views = views;
    }

    public Video getVideo() {
        return video;
    }

    public void setVideo(Video video) {
        this.video = video;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (videoid != null ? videoid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Rating)) {
            return false;
        }
        Rating other = (Rating) object;
        if ((this.videoid == null && other.videoid != null) || (this.videoid != null && !this.videoid.equals(other.videoid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entitys.Rating[ videoid=" + videoid + " ]";
    }
    
}
